<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>class的get和set</title>
</head>
<body>

</body>

<script>
class Phone{

    priceNum = 0;

    get getPrice(){
        console.log('获取到价格了'+ this.priceNum);
        return this.priceNum;
    }
    set setPrice(price){
        this.priceNum = price;
        console.log('设置价格为：'+ this.priceNum )
    }
}

let phone = new Phone();
phone.setPrice=199;
console.log(phone.getPrice);
</script>

</html>